package com.dilidili.controller;

import com.dilidili.service.IFansService;
import com.domain.Fans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-03-31
 */
@RestController
@RequestMapping("/system/fans")
public class FansController {
    @Autowired
    private IFansService fansService;

    @RequestMapping("onFans")
    public Object onFans(Integer userId, Integer bigvId) {
        Integer result = (Integer) fansService.offFans(userId, bigvId);
        if (result > 0) {
            Integer fans = (Integer) fansService.onFans(userId, bigvId, 0);
            Integer fans1 = (Integer) fansService.onFans(bigvId, userId, 0);
            return result;
        } else {
            Integer fans2 = (Integer) fansService.onFans(userId, bigvId, 1);
            return result;
        }
    }

    @RequestMapping("offFans")
    public Object offFans(Integer userId, Integer bigvId) {
        Integer result = (Integer) fansService.offFans(userId, bigvId);
        if (result > 0) {
            Integer integer = fansService.offFansUpd(bigvId, userId);
            return result;
        } else {
            return result;
        }
    }

    /**
     * 查询关注没关注
     *
     * @param userId
     * @param bigvId
     * @return
     */
    @RequestMapping("fansQuery")
    public Map fansQuery(Integer userId, Integer bigvId) {
        return fansService.fansQuery(userId, bigvId);
    }


    @RequestMapping("fansFandAll")
    public Fans fansFandAll(Integer userId, Integer bigvId) {
        return fansService.fansFandAll(userId, bigvId);
    }
}
